package wql.aaa.service.impl;

import com.aaa.entity.TbBanner;
import com.aaa.entity.TbZoneBusiness;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import wql.aaa.dao.ZoneBussinessDao;
import wql.aaa.service.TbBannerService;
import wql.aaa.dao.TbBannerMapper;
import org.springframework.stereotype.Service;
import wql.aaa.vo.BannerFormDta;
import wql.aaa.vo.SearchFormsData;

import java.util.List;

/**
* @author 咕噜咕噜
* @description 针对表【tb_banner(首页banner表)】的数据库操作Service实现
* @createDate 2023-02-28 11:24:54
*/
@Service
public class TbBannerServiceImpl extends ServiceImpl<TbBannerMapper, TbBanner>
    implements TbBannerService{

    @Autowired
    private TbBannerMapper tbBannerMapper;
    @Override
    public Result queryAll(int currentPage, int pageSize, BannerFormDta bannerFormDta) {
        PageHelper.startPage(currentPage,pageSize);

        List<TbBanner> byZoneId = tbBannerMapper.find(bannerFormDta);

        PageInfo<TbBanner> info = new PageInfo<>(byZoneId);

        return new Result(2000,"查询成功",info);
    }

    @Override
    public Result addBanner(TbBanner tbBanner) {
        tbBannerMapper.insert(tbBanner);

        return new Result(2000,"添加成功");
    }

    @Override
    public Result updateIsDisabled(Integer isDisable,String id) {
        tbBannerMapper.change(isDisable,id);
        return new Result(2000,"修改状态成功");
    }

    @Override
    public Result deleteByBannerId(String id) {
        int i = tbBannerMapper.deleteById(id);
        if (i>0){
            return new Result(2000,"删除成功");
        }else {
            return new Result(5000,"删除失败");
        }

    }

    @Override
    public Result updateLunBoTu(TbBanner tbBanner) {
        int i = tbBannerMapper.updateById(tbBanner);
        if (i>0){
            return new Result(2000,"修改成功");
        }else {
            return new Result(5000,"修改失败");
        }
    }
}




